package com.company.gjtx.common.util;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class PageView<T> implements Serializable {

	private static final long serialVersionUID = 1L;
	
	protected Integer currPage = 1;// 当前第几条数据
	
    protected Integer pageNum = 1;// 总页数，默认1
    
    protected Integer recNum;// 总记录数，默认1
    
    protected Integer recNumPerPage = 20;// 每页记录数，，默认20

    protected List<T> results = new ArrayList<T>();

    public PageView() {
        currPage = 1;
        recNumPerPage = 10;
        recNum = 0;
    }

    public PageView(int currPage, int recNum, int recNumPerPage) {
        this.currPage = currPage;
        this.recNum = recNum;
        this.recNumPerPage = recNumPerPage;

    }

    public int getCurrPage() {
        return currPage;
    }

    public void setCurrPage(int currPage) {
        this.currPage = currPage;
    }

    public int getPageNum() {
        if (recNumPerPage > 0) {
            int num = recNum / recNumPerPage;
            if (num * recNumPerPage < recNum)
                num++;
            return num;
        }
        return 1;
    }

    public int getRecNum() {
        return recNum;
    }

    public void setRecNum(int recNum) {
        this.recNum = recNum;
    }

    public int getRecNumPerPage() {
        return recNumPerPage;
    }

    public void setRecNumPerPage(int recNumPerPage) {
        this.recNumPerPage = recNumPerPage;
    }

	public List<T> getResults() {
		return results;
	}

	public void setResults(List<T> results) {
		this.results = results;
	}

}
